function* fibonacci() {
    let [prev, curr] = [0, 1]
    for(;;) {
        [prev, curr] = [curr, prev + curr]
        yield curr
    }
}

for(let n of fibonacci()) {
    console.log(n)
    if (n > 1000) break
}